package List.Vector;

import java.util.Vector;

/*
 * Description:Vector 简单演示
 * Author: AMark
 * Date:11/4/2023
 * Time:3:33 PM
 */
public class VectorDemo {
    public static void main(String[] args) {

        //增加数据
        Vector v = new Vector();
        for (int i = 0; i < 10; i++) {
            v.addElement(i);
        }
        System.out.println(v);

        //删除数据
        v.removeElement(5);
        System.out.println(v);

        //修改数据
        v.setElementAt(100, 5);
        System.out.println(v);

        //查找数据
        System.out.println(v.elementAt(5));

        //插入数据
        v.insertElementAt(200, 5);
        System.out.println(v);

        //获取数据
        System.out.println(v.firstElement());
        System.out.println(v.lastElement());

        //获取数据的索引
        System.out.println(v.indexOf(200));

        //获取数据的个数
        System.out.println(v.size());

        //判断是否为空
        System.out.println(v.isEmpty());

        //清空数据
        v.clear();
        System.out.println(v);
        System.out.println(v.isEmpty());
    }
}
